#include<stdio.h>
#include<unistd.h>
#include<pthread.h>

 pthread_rwlock_t rlock;
 void* st1(void* arg){
   
  pthread_rwlock_rdlock(&rlock);
  printf("第一次加锁成功\n");
  sleep(100);
 }
void* st2(void*arg){
sleep(1);

  pthread_rwlock_wrlock(&rlock);
  printf("第二次加锁成功\n");
}
int main(){

  pthread_rwlock_init(&rlock,NULL);
  for(int i=0;i<1;i++){
    pthread_t tid;
    pthread_create(&tid,NULL,st1,NULL);
    pthread_create(&tid,NULL,st2,NULL);
  }  

  sleep(100);
  return 0;
}
